package com.alibaba.nacos.config.server.jpa.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.GenericGenerator;

/**
 * @author
 * @date 2020-03-08 23:31
 * config_tag_relation
 */
@Entity
@Table(name = "NACOS_CONFIG_TAGS_RELATION",uniqueConstraints = {
    @UniqueConstraint(name = "UK_CONFIGTAGRELATION_CONFIGIDTAG", columnNames = {"ID","TAG_NAME","TAG_TYPE"})}
    ,indexes = @Index(name = "IDX_TENANT_ID",columnList = "TENANT_ID"))
public class ConfigTagsRelationEntity implements Serializable,IEntity {

    private static final long serialVersionUID = 1L;

    public ConfigTagsRelationEntity () {}

    /**
     * data_id
     */
    @Column(name = "DATA_ID", nullable = false)
    private String dataId;

    /**
     * group_id
     */
    @Column(name = "GROUP_ID", nullable = false)
    private String groupId;

    @Column(name = "ID", nullable = false)
    private Long id;
    /**
     * id
     */
    @Column(name = "NID")
    @Id
    @GeneratedValue(generator = "snowflake")
    @GenericGenerator(name = "snowflake", strategy = "com.alibaba.nacos.config.server.jpa.IdGenerator")
    private Long nid;

    /**
     * tag_name
     */
    @Column(name = "TAG_NAME", nullable = false)
    private String tagName;

    /**
     * tag_type
     */
    @Column(name = "TAG_TYPE")
    private String tagType;

    /**
     * tenant_id
     */
    @Column(name = "TENANT_ID")
    private String tenantId;

    public ConfigTagsRelationEntity setDataId(String dataId){
        this.dataId = dataId;
        return this;
    }

    public String getDataId(){
        return dataId;
    }

    public ConfigTagsRelationEntity setGroupId(String groupId){
        this.groupId = groupId;
        return this;
    }


    public String getGroupId(){
        return groupId;
    }

    public ConfigTagsRelationEntity setNid(Long nid){
        this.nid = nid;
        return this;
    }

    public Long getNid(){
        return nid;
    }

    public ConfigTagsRelationEntity setTagName(String tagName){
        this.tagName = tagName;
        return this;
    }

    public String getTagName(){
        return tagName;
    }

    public ConfigTagsRelationEntity setTagType(String tagType){
        this.tagType = tagType;
        return this;
    }

    public String getTagType(){
        return tagType;
    }

    public ConfigTagsRelationEntity setTenantId(String tenantId){
        this.tenantId = tenantId;
        return this;
    }

    public String getTenantId(){
        return tenantId;
    }

    /**
     * get id
     *
     * @return id
     */
    public Long getId() {
        return id;
    }

    /**
     * set id
     *
     * @param id id
     */
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("ConfigTagsRelationEntity = {");

        if (dataId != null){
            sb.append("dataId = ").append(dataId).append(", ");
        }
        if (groupId != null){
            sb.append("groupId = ").append(groupId).append(", ");
        }
        if (id != null){
            sb.append("id = ").append(id).append(", ");
        }
        if (nid != null){
            sb.append("nid = ").append(nid).append(", ");
        }
        if (tagName != null){
            sb.append("tagName = ").append(tagName).append(", ");
        }
        if (tagType != null){
            sb.append("tagType = ").append(tagType).append(", ");
        }
        if (tenantId != null){
            sb.append("tenantId = ").append(tenantId);
        }

        sb.append("}");
        return sb.toString();
    }

    @Override
    public void setPK(Long id) {
        setNid(id);
    }

    @Override
    public Long getPk() {
        return nid;
    }
}
